<template>
    <div>
    <van-row>
        <van-col span="24" class="back" ><heads/></van-col>
        <van-col span="6" class="back"><left/></van-col>
        <van-col span="18" class="back">
            <div>
                组织名称：<input type="text" placeholder="请输入组织名称"> <van-button color="blue" style="height:40px;width:90px">查询</van-button>&nbsp;&nbsp;<van-button color="blue" style="height:40px;width:90px">重置</van-button><br>
                <van-button color="blue" style="height:40px;width:90px">新增</van-button>    <van-uploader :after-read="upload"><van-button style="height:40px;width:90px">导入</van-button></van-uploader>
              <van-button style="height:40px;width:90px" @click="download">导出</van-button>
            </div>
             <cate :data=data @id=change />
            
        </van-col>
    </van-row>
    </div>
</template>

<script>
import fileDownload from "js-file-download";
import axios from 'axios'
import heads from '../components/heads'
import left from '../components/left'
import cate from '../components/cate'
    export default {
        components:{
            'left':left,
            'heads':heads,
            'cate':cate
     },
     data(){
         return{
            data:[]
         }
     },
     methods:{
         get_list(){
             axios({url:"organization",method:'get'}).then(res=>{
                 this.data=res.data.list
             })
         },
         change(id){
             alert(id)
         },
         //导入
         upload(file){
             let formdata = new FormData()
             formdata.append('file',file.file)
             axios({url:'upload',method:'post',data:formdata})
         },
       //导出
       download(){
           axios({url:'download',method:'get'}).then(res=>{
             fileDownload(res.data,'file.xls')
           })
       }
     },
     mounted(){
         this.get_list()
     }
    }
</script>

<style scoped>

</style>